Skip to content

Bugfix :: Fix codegen runtime crashes: TypeLoadException, InvalidProgramException, stack corruption#19338

Open
T-Gro wants to merge 12 commits intomainfrom
codegen/fix-runtime-crashes
Open

Bugfix :: Fix codegen runtime crashes: TypeLoadException, InvalidProgramException, stack corruption#19338
T-Gro wants to merge 12 commits intomainfrom
codegen/fix-runtime-crashes

Conversation

@T-Gro
Copy link
Member

@T-Gro T-Gro commented Feb 20, 2026

Fixes runtime exceptions caused by incorrect IL emitted for valid F# programs.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2026

✅ No release notes required

@T-Gro T-Gro force-pushed the codegen/fix-runtime-crashes branch 4 times, most recently from 68e48f0 to 3616853 Compare February 20, 2026 17:23
…k corruption

Fix 6 codegen bugs that cause hard crashes or invalid IL:
- #11132: voidptr delegate TypeLoadException
- #13447: tail. + localloc stack corruption
- #14492: inline constraints TypeLoadException in Release
- #14508: nativeptr in interfaces TypeLoadException
- #18319: literal upcast missing box instruction
- #18956: decimal literal InvalidProgramException in Debug

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@T-Gro T-Gro force-pushed the codegen/fix-runtime-crashes branch from 3616853 to 9549f87 Compare February 20, 2026 17:32
T-Gro and others added 4 commits February 26, 2026 15:12
Mark Issue_13447_TailInstructionCorruption and Issue_11132_VoidptrDelegate
tests with FactForNETCOREAPP to skip on net472 Desktop test runs.

- Issue_13447 uses Span<byte> which is not available on net472
- Issue_11132 uses voidptr in closure generic args which requires
  netcore runtime support

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@T-Gro T-Gro marked this pull request as ready for review March 6, 2026 18:32
@T-Gro T-Gro requested a review from a team as a code owner March 6, 2026 18:32
@T-Gro T-Gro changed the title WIP :: Bugfix :: Fix codegen runtime crashes: TypeLoadException, InvalidProgramException, stack corruption Bugfix :: Fix codegen runtime crashes: TypeLoadException, InvalidProgramException, stack corruption Mar 6, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
// When implementing an interface slot with nativeptr<'T> where 'T is an interface
// type parameter and the interface type args are concrete, the interface method
// returns 'native int'. The method def must also return 'native int' to match.
elif memberInfo.MemberFlags.IsOverrideOrExplicitImpl then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like GetMethodSpecForMemberVal should also check and rewrite params, not only return types. Just like GenActualSlotsig does at lines 5996-6025.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps there could even be some code reuse between this code here and the code at ~5996?

@github-project-automation github-project-automation bot moved this from New to In Progress in F# Compiler and Tooling Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment